<template>
  <div>
    <p>{{num}}</p>
    <Child ref="child"></Child>
  </div>
</template>

<script>
  import Child from "./components/Child";
  
  export default {
    name: "App",
    data() {
      return {
        num: 0
      }
    },
    components:
      {
      Child
      },
    mounted() {
      this.$refs.child.$on('add',(num)=>{
        this.num += num
      })
    }
  }
</script>

<style scoped>

</style>